﻿@{
    ViewBag.Title = "Login";
    Layout = "~/Views/Shared/_IndexLayout.cshtml";
}
<link href="~/Content/login/login.css" rel="stylesheet" />
<body >
    <div class="login" style="text-align:center ">
        <div style="margin-top:-32px;"><img src="../images/rxd.jpg" alt="" style="width:180px;height:60px"></div>
        <div class="message">数据采集信息管理系统</div>
        <div id="darkbannerwrap"></div>
        <form id="upForm">
            <input id="usercode" placeholder="账号" type="text" />
            <input id="password" placeholder="密码" type="password" style='margin-top: 20px' />
            <input value="登 录" id="login" style="width: 100%; margin-top: 20px" type="button" />
        </form>
    </div>
</body>
<script type="text/javascript">

    (function () {
        $("#login").on("click", login);
        $(document).keyup(function (event) {
            if (event.keyCode === 13) {
                login();
            }
        });

        //登陆函数
        function login() {
            var usercode = $('#usercode').val(),
                password = $('#password').val();
            if (usercode && password) {
                com.ajax({
                    url: "/Home/LoginMethod",
                    type: "POST",
                    //async:false,
                    data: {
                        "usercode": usercode,
                        "password": password
                    },
                    success: function (data) {
                        if ("success" == data.state) {
                            window.location.href = "/Home/Index"
                        } else {
                            $.messager.show({
                                title: 'Error',
                                msg: data.msg,
                                showType: 'show'
                            });
                            $('#password').val('');
                        }
                    }
                });
            } else {
                $.messager.show({
                    title: 'Error',
                    msg: '账号和密码不能为空',
                    showType: 'show'
                })
            }
        }
    })()

</script>
